﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Webshop.Models;

namespace Webshop.Controllers
{
    public class StoreController : Controller
    {
        WebshopEntities storeDB = new WebshopEntities();
       
        public ActionResult Browse(string category)
        {
            var categoryModel = storeDB.Categories.Include("Products").Single(c => c.Name == category);
            return View(categoryModel);
        }
       
        public ActionResult Details(int id)
        {
            var product = storeDB.Products.Find(id);
            return View(product);
        }

        public ActionResult Index()
        {
            var categories = storeDB.Categories.ToList();
            return View(categories);
        }

        // GET: /Store/CategoryMenu
        [ChildActionOnly]
        public ActionResult CategoryMenu()
        {
            var categories = storeDB.Categories.ToList();
            return PartialView(categories);
        }
    }
}